package com.midele.goodstuff.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.midele.goodstuff.ui.main.MainPageIntent
import com.midele.goodstuff.ui.main.MainPageState
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

class ExploreViewModel : ViewModel() {

    private val _state = MutableStateFlow(MainPageState())
    val state: StateFlow<MainPageState> = _state.asStateFlow()

    fun processIntent(intent: MainPageIntent) {
        viewModelScope.launch {
            when (intent) {
                is MainPageIntent.ChangePagePosition -> _state.value = MainPageState(pagePosition = intent.position)
            }
        }
    }
}